﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CrackPrj
{
    public partial class TestForm : Form
    {
        public TestForm()
        {
            InitializeComponent();
          
        }

        private void TestButton_Click(object sender, EventArgs e)
        {
            //试件
            var specimen = new Specimen("测试", 0, 0, 0, 3000, 500);
            //状态A
            var stateA = new SpecimenState(0.1); specimen.Add(stateA);
            //添加裂缝
            var crack1 = new Crack(); crack1.Add(new Node(200, 0)); crack1.Add(new Node(200, 100));
            var crack2 = new Crack(); crack2.Add(new Node(200, 500)); crack2.Add(new Node(200, 400));
            //压溃区
            var crush = new Crush(); crush.Add(new Node(0, 0)); crush.Add(new Node(100, 0));
            crush.Add(new Node(50, 100)); crush.Add(new Node(0, 100));
            //添加裂缝
            stateA.Add(crack1); stateA.Add(crack2); stateA.Add(crush);
            //绘图
            specimen.ToGraphics(0, this.Chart2DBasic);
            //生成文件
            specimen.ToFile(@"G:\Gitee\GBCodeSpecturmDemo\Json");

        }

        /// <summary>
        /// 选择文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenButton_Click(object sender, EventArgs e)
        {
            //反序列化对象
            Specimen specimen;
            if (!Specimen.GetSpecimen(out specimen)) return;
            //绘图
            specimen.ToGraphics(0, this.Chart2DBasic);
        }
    }
}
